<!-- File: /app/views/posts/view.ctp -->
<?php
?>

<br/>
<span class="postTitle">
<?php echo $post['Post']['title']?></span><br/>

<div class="post2">


<p><small>
        
        Created: <?php 
    
        echo $post['Post']['created']?></small></p>




<?php echo $this->Html->script('jquery.color.js', false); ?>


<div class="tags1">
    <b>Tags:</b> 
    
    <?php 
    if ($session->check('Auth.User.id')) 
  echo '<a href="#" onclick="return editTags1(this);" class="moreless"> [Edit]</a>';
    ?>
    
    
    <span class="tags2">
    <?php 
    $tags1="";
   
    foreach ($post['Tag'] as $tag) {
                   if (strpos($tag['tag'],"board:")!==false)
                     echo "<a class='boardLink' href='../search/?search=".$tag['tag']."'>".$tag['tag']."</a>, ";
                 else if (strpos($tag['tag'],"test:")!==false)
                     echo "<a class='boardLink1' href='../search/?search=".$tag['tag']."'>".$tag['tag']."</a>, ";
                 else
                     echo "<a href='../search/?search=".$tag['tag']."' >".$tag['tag']."</a>, ";
          $tags1.=$tag['tag']." ";
          }
        ?>
    </span>
    <div id="tags" style="display:none;">
        <?php echo $form->create('Tag', array('action'=>'add'));?>
    <?php echo $form->input(
        'Post.id', 
        array('type'=>'hidden', 'id'=>'postId', 'value' => $post['Post']['id'])); ?>
    <?php echo $form->input('Tag.tag', array('label'=>'', 'value'=>$tags1, 'type' => 'textarea')); ?>
    <?php echo $form->end('Add Tag'); ?>
    </div>
</div>
        <p><?php echo $post['Post']['body']?></p>
</div>

<br/><br/><br/>
<div class='smash' id="smash">
<!--onclick='return setTextual(this)'-->
 
<div id="smash1" style="display:inline-block; clear:none;"  >
	<?php
        echo $html->script('jquery-ui-1.8.14.custom.min', true);
	echo $html->script('jquery.fileUploader', true);
	echo $html->css('ui-lightness/jquery-ui-1.8.14.custom', null, array(), true);
	echo $html->css('fileUploader', null, array(), true);
		echo $this->Form->create('Attachment', array('action'=> 'add', 'type' => 'file'));
		echo $this->Form->input('file', array(
			'type' => 'file', 
			'label' => false, 'div' => false,
			'class' => 'fileUpload', 
			'multiple' => 'multiple',
                        'onclick' => 'return setTextual(this)'
		));		
		echo $this->Form->button('Upload', array('type' => 'submit', 'id' => 'px-submit', 'style'=> 'display:none'));
		echo $this->Form->button('Clear', array('type' => 'reset', 'id' => 'px-clear'));
		echo $form->end();
	?>

</div>
<div id="chicken" style="display:inline-block; width:400px; clear:none; vertical-align:top">

</div> 

<script type="text/javascript">
	$(function(){
		$('.fileUpload').fileUploader();
	});
</script>

<?php 
//$testums = $this->Html->link('↑',   array('controller' => 'Comments', 'action' => 'up'), 5,    array(),    "Are you sure you want to upvote?");
//echo $testums;
//echo $testums;

//$this->Paginator->options(array(
//    'update' => '#content',
//    'evalScripts' => true
//));



//
//function sechungpark($com, &$output) {
//    global $testums;
//    foreach ($com as $com1) {
//      $output.="<div class='post1'>";
//      $output.=$com1['Comment']['id']."<br/>";
//     
//      $output.="<b>".$com1['Comment']['name']."</b> --".$com1['Comment']['email']." <span>".($com1['Comment']['up']-$com1['Comment']['down'])."</span> points";
//      $output.="<span>";
//      $output.='<a href="javascript:void(0)" onclick="return updown('.$com1['Comment']['id'].',1, this)" class="updown"><b>↑</b></a>';
//      $output.='<a href="javascript:void(0)" onclick="return updown('.$com1['Comment']['id'].',-1, this)" class="updown"><b>↓</b></a><br/>';
//      $output.="</span>";
//       // "  <a href='#'class='updown' onclick=''>↓</a><br/>";
//      
////      echo $this->Html->link('↑',    array('controller' => 'Comments', 'action' => 'up', $com1['Comment']['id']),    array('class'=>'updown'),    "Are you sure you want to upvote?");
////     echo $this->Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank'));
////              "<a href='#' class='updown' onclick=''></a><a href='#'class='updown' onclick=''>↓</a><br/>";
//      $output.= $com1['Comment']['text']."<br/>";
//      $output.="<a style='float:right;' href='#' onclick='return reply(".$com1['Comment']['id'].")'>Reply</a><br/><br/>";
//      $output.="</div>";
//      $output.="<div class='post'>";
//      if (isset($com1['Comment']['replies']))
//          sechungpark($com1['Comment']['replies'], $output);
//       $output.="</div>";
//       
//      }
//   
//      
//    }



echo "<div id='mycomment'>";
echo $this->Form->create('Comment', array('action' => 'add', 'id'=>'mycomment1'));
echo $this->Form->input('Comment.parent_id', array('type' => 'hidden', 'value' => '0'));
echo $this->Form->input('Post.id', array('type' => 'hidden', 'value' => $post['Post']['id']));
echo "<a href='javascript:void(0)' class='moreless' onclick='showhide(this)' >[Options]</a><span class='name' style='display:none;'>";
echo $this->Form->input('Comment.name', array('class'=>'name1'));
echo $this->Form->input('Comment.password', array('class'=>'name1'));
echo "</span>";
echo $this->Form->input('Comment.text', array('class'=>'texting', 'id'=>'textual'));
echo $this->Form->button('Add comment', array('type'=>'button','onclick'=>'return comment(this)', 'class'=>'cancel'));
echo $this->Form->button('Cancel', array('type'=>'button', 'class'=>'cancel1', 'onclick'=>'return cancel(this)'));
 echo $this->Form->end(); 

echo "<br/><br/></div></div>";
echo "<hr/><br/>";
echo '<div class="input select"><select name="data[Post]" id="SortPost" onchange="return onChange('.$post['Post']['id'].', this)">
<option value="Comment.Created">date</option>
<option value="Comment.Up">popularity</option>
<option value="Comment.Down">best</option>
</select></div><br/>';
//print_r($post['Comment']);
$x=1;
if (!file_exists("comments/".$post['Post']['id'].".html")){
//$output="";
//
//sechungpark($com,$output);
//
////echo file_put_contents("comments/".$post['Post']['id'].".html",$output);
//echo $output;      
//echo "shit";
    echo "<div id='comments'>";
     echo $this->element("sechungpark");
    echo "</div>;";
}
else
    {
      echo file_get_contents("comments/".$post['Post']['id'].".html");
    }
//echo $this->Form->create('Comment', array('action' => 'add'));
//
//echo $this->Form->input('name');
//echo $this->Form->input('email');
//echo $this->Form->input('text', array('rows' => '3'));
//echo $this->Form->end('Save Comment');


echo "<div id='deleteComment'>";
echo $form->create('Comment', array('action'=>'delete'));
echo $form->input(
        'Comment.id', 
        array('type'=>'hidden', 'id'=>'deleteCommentId', 'value' => ''));
echo $form->input('Comment.password');
echo $form->end('Delete');
echo $this->Form->button('Cancel', array('onclick'=>'hideDelete(this)'));
echo "</div>";
echo "<div id='editComment'>";
echo $form->create('Comment', array('action'=>'edit'));
echo $form->input(
        'Comment.id', 
        array('type'=>'hidden', 'id'=>'deleteCommentId', 'value' => ''));
echo $form->input('Comment.text');
echo $form->end('Save');
echo $this->Form->button('Cancel', array('onclick'=>''));
echo "</div>";

?>